/*
 * FORMULA ARDUINO
 * Road setup header file
 * 
 * Using PROGMEM directive to store this massive data on flash, not in RAM
 * 
 * Developed by rikovmike 
 * mike@rikovmike.ru
 * 
 * ver a1.0 
 */

/* road blocks IDs:

  0 - road
  1 - full Block
  2 - grid Block
  3 - palm block (safe)
  4 - sand block (safe)
  
  -- randomized blocks
  5 - score bonus ($)
  6 - speed powerup (->)

  
*/


const int roadBlocks[7] {0,255,35,42,46,36,201}; // Charcodes of blocks by ID

const int safeBlocks[2] {3,4};  //Safe blocks ID's

const int bonusBlocks[2] {5,6};  //Bonus blocks ID's

int currPattern[9][4];    // Current pattern array. Used by RoadMover to fill offscreen part of draw-buffer.
int lastPatternResolveredPattern=1; // Last selected pattern by resolver. We use resolvers for smooth and correct use of road patterns without casualities


/*
 * Main Road array initial data. Saving in RAM. 
 */

const int roadArrayInit[27][4]={
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {2,0,0,2},
    {2,0,0,2},
    {0,0,0,0},
    {0,0,0,0},
    {84,0,0,84},
    {82,0,0,82},
    {65,0,0,65},
    {84,0,0,84},
    {83,0,0,83},
    {0,0,0,0},
    {0,0,0,0},
    {0,0,0,0}
  };

/*
 * Main Road Array. Used by Road mover and Road drawer
 */

int roadArray[27][4];


/*
 * Road patterns
 */


const int patterns[15][9][4] PROGMEM={
  
  {
    {0,0,0,4},
    {4,0,0,0},
    {0,0,4,0},
    {0,0,0,0},
    {0,4,0,0},
    {0,0,0,4},
    {4,0,0,0},
    {0,0,4,0},
    {0,0,0,4},
  },

{
    {0,0,0,3},
    {0,0,0,0},
    {3,0,0,0},
    {0,0,0,0},
    {0,0,0,3},
    {0,0,0,0},
    {0,0,0,0},
    {3,0,0,0},
    {0,0,0,0},
  },

{
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
  },



{
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
  },

{
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
  },

{
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
    {1,0,1,1},
  },




{
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
  },

{
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
  },

{
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,0,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
    {1,1,0,1},
  },





{
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,0,1,1},
    {0,0,1,1},
    {0,0,1,1},
    {0,0,0,1},
    {0,0,0,1},
    {0,0,0,1},
  },

{
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
  },

{
    {0,0,0,1},
    {0,0,0,1},
    {0,0,0,1},
    {0,0,1,1},
    {0,0,1,1},
    {0,0,1,1},
    {0,1,1,1},
    {0,1,1,1},
    {0,1,1,1},
  },




{
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,0,0},
    {1,1,0,0},
    {1,1,0,0},
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
  },

{
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
  },

{
    {1,0,0,0},
    {1,0,0,0},
    {1,0,0,0},
    {1,1,0,0},
    {1,1,0,0},
    {1,1,0,0},
    {1,1,1,0},
    {1,1,1,0},
    {1,1,1,0},
  }



};


/*
 * Pattern resolvers. Each pattern can cast next pattern only by resolver rules!
 */

const int pattern_resolvers[15][7] PROGMEM= {
    {1,2,3,4,7,10,13},
    {1,2,3,4,7,10,13},
    {1,2,3,4,7,10,13},
    {5,6,5,6,5,5,6},
    {5,6,5,5,5,6,5},
    {1,2,3,4,7,10,13},
    {8,9,8,9,8,9,8},
    {8,9,8,8,8,9,8},
    {1,2,3,4,7,10,13},
    {11,12,11,12,11,12,11},
    {11,12,11,11,11,12,11},
    {1,2,3,4,7,10,13},
    {14,15,15,14,15,14,15},
    {14,15,14,14,14,15,15},
    {1,2,3,4,7,10,13}
};
